package io;

import java.io.File;
import java.io.IOException;

public class FileLastModifiedTest {
	private static File f = new File("1");

	public static void main(String[] args) throws Exception {
		touchFile(f);
		printFileLastModified();
		new Thread(){
			public void run() {
				try {
					Thread.sleep(500);
					File f = new File("1");
					touchFile(f);
				} catch (IOException e) {
					e.printStackTrace();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			};
		}.start();
		Thread.sleep(1000);
		printFileLastModified();
	}

	private static void touchFile(File file) throws IOException {
		file.delete(); // if does not exist, will skip
		file.createNewFile(); // if exists already, will skip
	}
	
	private static void printFileLastModified() {
		System.out.println(f.lastModified());
	}
}
